﻿//========================================================= 
/**@file VBoxInstaller.h
 * @brief 支持虚拟设备的驱动装载器
 * 
 * @date 2017-11-06   23:20:54
 * @author Zhyioo 
 * @version 1.0
 */ 
//--------------------------------------------------------- 
#ifndef _LIBZHOUYB_VBOXINSTALLER_H_
#define _LIBZHOUYB_VBOXINSTALLER_H_
//--------------------------------------------------------- 
#include "H002Installer.h"

#include "../device/VirtualDeviceCmdDriver.h"
//--------------------------------------------------------- 
namespace zhou_yb {
namespace application {
namespace driver {
//--------------------------------------------------------- 
/**
 * @brief 装载虚拟的设备模块到驱动中
 * @date 2017-11-06 23:21:55
 */
class VBoxInstaller
{
protected:
    VBoxInstaller() {}
public:
    static void Install(CommandRunner& runner)
    {
        const char DEV_ID[] = "VirtualDEV";
        const char DEV_RECODER[] = "VDevRecoder";

        H002Installer installer(runner);
        installer.InstallDEV<FileVirtualDeviceCmdDriver>(DEV_ID);
        
        Ref<CachedRecorderCmdDriver> vdevRecoder;
        CommandInstaller::RegisteNew<CachedRecorderCmdDriver>(runner, DEV_RECODER, &vdevRecoder);

        CommandSetter setter(runner);
        Ref<CommandScriptActuator> scriptSelect = installer.NewScriptCMD(DEV_ID);
        scriptSelect->Run(runner.LookUp("DEV.IInteractiveTrans")).ToArg()
            .Run(vdevRecoder->LookUp("SelectDevice")).Clear(true, true)
            .Run(vdevRecoder->LookUp("IInteractiveTrans")).ToArg()
            .Run(runner.LookUp("Select_IBaseDevice")).Clear(true, true)
            .Run(runner.LookUp("IInteractiveTrans")).ToArg()
            .Run(runner.LookUp("Select_IInteractiveTrans"));

        Ref<CommandScriptActuator> script = installer.BindCMD(DEV_RECODER, "", "Write;Read;IInteractiveTrans");
        string cmdName = DEV_RECODER;
        cmdName += ".Capture";
        setter.New(cmdName.c_str())
            .Bind(script->Script("AutoBindCapture"))
            .Bind(scriptSelect->Script("AutoSelectCapture"));
    }
};
//--------------------------------------------------------- 
} // nemespace driver
} // namespace application
} // namespace zhou_yb
//--------------------------------------------------------- 
#endif // _LIBZHOUYB_VBOXINSTALLER_H_
//========================================================= 